def count_word(filename):
    try:
        with open(filename) as file_object:
            contents = file_object.read()
    except FileNotFoundError:
        # msg = "Sorry, the file " + filename + " does not exist."
        # print(msg)
        pass
    else:
        # 计算包含多少单词
        words = contents.split()
        num_words = len(words)
        print("The file " + filename + " has about " + str(num_words) +
              " words.")


filename = 'alice.txt'
count_word(filename)

filenames = ['alice.txt', 'a.txt', 'moby_dick.txt', 'little_women.txt']
for filename in filenames:
    count_word(filename)
